package com.dxq.test.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dxq.test.R;
import com.dxq.test.db.Event;
import com.dxq.test.db.Label;

import java.util.List;

/**
 * Author: zsh
 * Date: 2023/11/15
 * Describe: 牲畜列表adapter
 */
public class StockAdapter extends BaseQuickAdapter<Label, BaseViewHolder> {

    public StockAdapter(int layoutResId) {
        this(layoutResId, null);
    }

    public StockAdapter(int layoutResId, @Nullable List<Label> data) {
        super(layoutResId, data);
        addChildClickViewIds(R.id.ivCheck);
    }

    @Override
    protected void convert(BaseViewHolder holder, Label item) {
        //holder.setText(R.id.tvSize, String.valueOf(1 + holder.getLayoutPosition()));
        holder.setText(R.id.tvID, item.getID());
        holder.setText(R.id.tvName, item.getName());
        String sex = item.getSex();
        holder.setText(R.id.tvSex, sex);
        boolean check = item.isCheck();
        if (check) {
            holder.setBackgroundResource(R.id.ivCheck, R.drawable.ic_baseline_check_circle_24);
        } else {
            holder.setBackgroundResource(R.id.ivCheck, R.drawable.ic_baseline_radio_button_unchecked_24);
        }
        boolean exist = item.isExist();
        holder.setEnabled(R.id.ivCheck, !exist);
    }
}
